
#[cfg(not(feature = "address_proto"))]
#[derive(Clone, Copy)]
pub struct Proto<T> {
    pub ty: u8,
    pub seq: u8,
    pub body: T,
}

#[cfg(feature = "address_proto")]
#[derive(Clone, Copy)]
pub struct Proto<T> {
    pub ty: u8,
    pub seq: u8,
    pub src: u8,
    pub dst: u8,
    pub body: T,
}


#[derive(Clone, Copy)]
pub struct Cmd<T> {
    pub cmd: u8,
    pub body: T,
}

#[derive(Clone, Copy)]
pub struct Res<T> {
    pub cmd: u8,
    pub ec: u8,
    pub body: T,
}

pub trait ToEc {
    fn to_ec(self) -> u8;
}

impl <T: ToEc + Copy> ToEc for &T {
    fn to_ec(self) -> u8 {
        (*self).to_ec()
    }
}

#[derive(Clone, Copy)]
pub struct Res2<T, E> {
    pub cmd: u8,
    pub ret: Result<T, E>,
}
